import sys

def error(code, argv):
    argv.extend([' ', ' ', ' ', ' '])
    mesg =  'Spass error: '

    res = {
        'custom' : str(argv[0]),
        'not.root' : str("SPASS_ROOT is not set up. SPASS aborted"),
    	'args.need' :  str("The command " + argv[0] + " needs some arguments. "\
                               "Please type \"spass " + argv[0] + " --help\""\
                               "for more informations"),
        'must.dir' : str(argv[0] + " is not a directory"),
    	'init.find' : str("Please make \"spass init\" to set up spass first"),
        'warehouse.find' : str("Cannot find the warehouse"),
        'command.find' : str("Cannot find \"" + argv[0] +"\" command"),
        'template.find' : str("The template " + argv[0] + " cannot be found"),
        'assignment.find' : str("The assignment " + argv[0] +
                                " cannot be found"),
        'ateam.find' : str("The team " + argv[1] +
                           " is not a part of the assignment " + argv[0]),
        'atest.find' : str("The test " + argv[1] +
                           " is not a part of the assignment " + argv[0]),
        'avf.find' : str("The assignment version "
                         + argv[0] + "." + argv[1] + "." + argv[2] +
                         " does not contain the file " + argv[3]),
        'avt.find' : str("The assignment version " + argv[0] + "."
                         + argv[1] + "." + argv[2] + " does not contain the "\
                             "test log " + argv[3]),
        'av.find' : str("The assignment version " + argv[0] + "." + argv[1] +
                        "." + argv[2] + " does not exist"),
        'not.find' : str("Cannot find " + argv[0]),
        'not.found' : str(argv[0] + ' ' + argv[1] + " does not exist"),
        'assignment.exists' : str("The assignment " + argv[0] +
                                  " already exists"),	
        'avf.exists' : str("The assignment version " + argv[0] + "." + argv[1] +
                           "." + argv[2] + " already contains the file "
                           + argv[3]),
        'avt.exists' : str("The assignment version " + argv[0] + "." + argv[1] +
                           "." + argv[2] + " already contains the test log "
                           + argv[3]),
        'av.exists' : str("The assignment version " + argv[0] + "." + argv[1] +
                          "." + argv[2] + " already exists"),
        'file.exists' : str(argv[0] + " already exists"),
        'already.exists' : str(argv[0] + ' ' + argv[1] + " already exists"),
        'supervisor.of' : str("User " + argv[0] +" is currently supervisor of "\
                                  "assignment(s). Deletion aborted"),
        'already.into' : str(argv[0] + " already exists in " + argv[1]),
        'not.into' : str(argv[0] + " does not exist in " + argv[1]),
        'manpower' : str(argv[0] + " has a manpower " + argv[1] +
                         " than the template's rule"),
        'date.assert' : str("Date must be YYYY-MM-DD"),
        'year.assert' : str("Year must be between "+argv[0]+" and "+argv[1]),
        'month.assert' : str("Month must be between 01 and 31"),
        'day.assert': str("Day must be between 01 and 31"),
        'no.plugin' :str("No plugin found"),
        'no.file' : str("No file found"),
        'no.version' : str("No version found"),
        'no.descr' : str("No description found for the plugin " + argv[0]),
        'no.lang' : str("No langage description found for the plugin "
                        + argv[0]),
        'no.test':str("No test found"),
        'user.notfound' : str("User " + argv[0] + " not found"),
        'team.notfound' : str("Team " + argv[0] + " not found"),
        'teamset.notfound' : str("TeamSet " + argv[0] + " not found"),
        'template.notfound' : str("Template " + argv[0] + " not found"),
        'not.archive' : str("File "+argv[0]+" is not an archive file"),
        'extension' : str("Extension "+argv[0]+ " is not supported")
    }
    mesg += res.get(code) + "."
    sys.stderr.write(mesg)
    print ''

